﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KL.Store.Core;
using KL.Store.Core.Domain;
using TN.Data;

namespace KL.Store.Data
{
    public class dbCity
    {
        #region GetDDL

        public static IList<City> GetAll()
        {
            IList<City> objectList = new List<City>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_City_List", objectList);
            if (objectList == null)
            {
                objectList = new List<City>();
            }
            return objectList;
        }

        #endregion

        #region GetDDL

        public static IList<CityDDL> GetList(int CountryId)
        {
            IList<CityDDL> objectList = new List<CityDDL>();

            //SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_City_ListDDL", objectList, new object[] { CountryId });

            objectList = Parameters.CityList.Where(c => c.CountryId == CountryId).Select(c => new CityDDL(c.CityId, c.CityName, c.FreeCargo)).ToList<CityDDL>();
            if (objectList == null)
            {
                objectList = new List<CityDDL>();
            }
            CityDDL cityDDL = new CityDDL(0, "İl Seçiniz", false);
            objectList.Insert(0, cityDDL);

            return objectList;
        }

        #endregion

        #region GetFreeCargoCities

        public static IList<CityDDL> GetFreeCargoCities()
        {
            IList<CityDDL> objectList = new List<CityDDL>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_City_List_FreeCargo", objectList);

            return objectList;
        }

        #endregion

        #region GetRegions

        public static IList<Region> GetRegions()
        {
            IList<Region> objectList = new List<Region>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Region_List", objectList);
            if (objectList == null)
            {
                objectList = new List<Region>();
            }
            return objectList;
        }

        #endregion

        
    }
}
